Simple Scheduler |
Copyright (c) 2003 Atmel
In config.h:1/ SCHEDULER_TYPE (required) SCHEDULER_FREE: free running (max perfs, none constrainst) SCHEDULER_TIMED: a semaphore is used to activate a new schedule (for instance all the tasks are executed each ms) SCHEDULER_TASK: a semaphore is used between each task (for instance each task is executed each ms) SCHEDULER_CUSTOM: custom, it is possible to define another scheduler type
2/ Scheduler_task_x_init (optional, except Scheduler_task_1_init) x from 1 to 9, defines the init functions (init of task or general purpose init)
3/ Scheduler_task_x (optional, except Scheduler_task_1) x from 1 to 9, defines the task functions
4/ Scheduler_time_init (optional) defines the function that will be called to initialize time events: soft timers, tempo...
5/ SCHEDULER_ENABLE_IT (optional) allow to enable interrupts after all initializations
6/ '#define scheduler main' (optional) if the main is only a call to the scheduler
EXAMPLE ------- | |// File: config.h |#define Scheduler_time_init init_soft_timers | |#define Scheduler_task_1_init twi_lib_init |#define Scheduler_task_2_init init_leds_task |#define Scheduler_task_3_init stdo_init |#define Scheduler_task_4_init init_main_task |#define Scheduler_task_5_init stdi_init | |#define Scheduler_task_1 leds_task |#define Scheduler_task_3 main_task |#define Scheduler_task_4 stdi_update_kbhit | |#define SCHEDULER_TYPE SCHEDULER_FREE |
// File: scheduler.c / scheduler.h (after precompiler) void scheduler_init (void) { init_soft_timers(); twi_lib_init(); init_leds_task(); stdo_init(); init_main_task(); stdi_init(); ; }
void scheduler_tasks (void) { scheduler_empty_fct(); for(;;) { leds_task(); ; main_task(); ; stdi_update_kbhit(); ; ; } }
void scheduler (void) { scheduler_init(); scheduler_tasks(); }
void scheduler_empty_fct (void) { }
scheduler_tick_flag
scheduler scheduler_empty_fct scheduler_init scheduler_tasks
bit scheduler_tick_flag |
When SCHEDULER_TYPE != SCHEDULER_FREE, this flag control task calls.
void scheduler ( void ) |
Simply call this task to init & run the scheduler
* return: |
void scheduler_empty_fct ( void ) |
This function does nothing
* return: |
void scheduler_init ( void ) |
Scheduler initialization
* return: |
Task_x_init() and Task_x_fct() are defined in config.h
void scheduler_tasks ( void ) |
Task execution scheduler
* return: |